import ajax from '@/utils/http/request';
import {
  IHospitalListParams,
  IResHospitalListData,
  IResProvince,
  IResScheduleListData,
  IResScheduleRules,
  IScheduleData,
} from './model/hospitalListType';

// 获取医院列表
export const reqHospitalList = (page = 1, limit = 5, params?: IHospitalListParams) =>
  ajax.get<any, IResHospitalListData>(`/admin/hosp/hospital/${page}/${limit}`, {
    params,
  });

// 上线与下线
export const reqUpdateStatus = (id: string, status: 0 | 1) =>
  ajax.get<any, null>(`/admin/hosp/hospital/updateStatus/${id}/${status}`);

// 获取省级数据的接口
export function reqGetProvinceList(province: string = 'province') {
  return ajax.get<any, IResProvince[]>(`/admin/cmn/dict/findByDictCode/${province}`);
}

// 获取市或区数据的接口
export function reqGetCityOrDistrictList(parentId: string) {
  return ajax.get<any, IResProvince[]>(`/admin/cmn/dict/findByParentId/${parentId}`);
}

// 获取科室数据
export function reqSchedule(hoscode: string) {
  return ajax.get<any, IScheduleData[]>(`/admin/hosp/department/${hoscode}`);
}

// 获取排班规则数据
export function reqScheduleRules(page: number, limit: number, hoscode: string, depcode: string) {
  return ajax.get<any, IResScheduleRules>(`/admin/hosp/schedule/getScheduleRule/${page}/${limit}/${hoscode}/${depcode}`);
}

// 获取workDate排班日期的排班详细列表
export function reqScheduleList(hoscode: string, depcode: string, workDate: string) {
  return ajax.get<any, IResScheduleListData[]>(`/admin/hosp/schedule/findScheduleList/${hoscode}/${depcode}/${workDate}`);
}
